package com.example.system.controller;

import com.example.common.Result;
import com.example.system.entity.Druginfo;
import com.example.system.entity.User;
import com.example.system.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2023-05-03
 */
@RestController
@RequestMapping("/system/user")
@CrossOrigin
public class UserController {
    @Autowired
    private IUserService userService;

    @GetMapping("/all")
    public Result<List<User>> getallUser(){
        List<User> list = userService.list();
        return new Result<>(200,"请求成功",list);
    }
    @PostMapping("/login")
    public Result<Map<String,Object>> login(@RequestBody User user){
        Map<String,Object> data =userService.login(user);
        if (data != null){
            return  new Result<>(200,"登陆成功",data);
        }
        return null;
    }

    }


